<script setup>
import { onMounted, onUnmounted } from "vue";
import AMapLoader from "@amap/amap-jsapi-loader";

let map = null;

onMounted(() => {
  window._AMapSecurityConfig = {
    securityJsCode: "f57d700708ffcf4676b3a22e2baa0fb8",
  };
  AMapLoader.load({
    key: "ae7d37a5d768e5a08aa3449a6f7f727a", // 申请好的Web端开发者Key，首次调用 load 时必填
    version: "2.0", // 指定要加载的 JSAPI 的版本，缺省时默认为 1.4.15
    plugins: ["AMap.Scale", "AMap.HawkEye", "AMap.ToolBar", "AMap.ControlBar"], //需要使用的的插件列表，如比例尺'AMap.Scale'，支持添加多个如：['...','...']
  })
    .then((AMap) => {
      var scale = new AMap.Scale(),
        toolBar = new AMap.ToolBar({
          position: {
            top: '110px',
            right: '40px'
          }
        }),
        controlBar = new AMap.ControlBar({
          position: {
            top: '10px',
            right: '10px',
          }
        }),
        overView = new AMap.HawkEye({
          opened: false
        }),
        map = new AMap.Map("container", {
          viewMode: '3D',
          zoom: 11,
          pitch: 30,
        });
      map.addControl(scale);
      map.addControl(toolBar);
      map.addControl(controlBar);
      
      })
    .catch((e) => {
      console.log(e);
    });
});

onUnmounted(() => {
  map?.destroy();
});
</script>

<template>
  <div id="container"></div>
</template>

<style scoped>
#container {
  width: 100%;
  height: 800px;
}

</style>
